import { Element } from './UI';

export class Spinner extends Element
{
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    dom: HTMLInputElement;
    constructor()
    {
        super();
        const dom = document.createElement('input');
        this.dom = dom;
    }

    onAdded()
    {
        super.onAdded();
        $(this.dom).spinner();
    }
}

export class Datepicker extends Element
{
    constructor()
    {
        super();
        const dom = document.createElement('input');
        dom.type = 'text';
        this.dom = dom;
        // <input type="text" id = "datepicker" >
    }

    onAdded()
    {
        super.onAdded();
        $(this.dom).datepicker().change(() =>
        {
            this.emit('change');
        });
    }

    get value()
    {
        return $(this.dom).datepicker('getDate');
    }

    set value(v)
    {
        $(this.dom).datepicker('setDate', v);
    }
}
